﻿using System;
using ExFlash.Records;

namespace ExFlash.Tags
{
    public class DefineMorphShapeTag : Tag
    {
        public ushort CharacterId
        {
            get;
            protected set;
        }

        public RectangleRecord StartBounds
        {
            get;
            protected set;
        }

        public RectangleRecord EndBounds
        {
            get;
            protected set;
        }

        public uint Offset
        {
            get;
            protected set;
        }

        public MorphFillStyleArray MorphFillStyles
        {
            get;
            protected set;
        }

        public MorphLineStyleArray MorphLineStyles
        {
            get;
            protected set;
        }

        public Shape StartEdges
        {
            get;
            protected set;
        }

        public Shape EndEdges
        {
            get;
            protected set;
        }

        public DefineMorphShapeTag(int len, int offset)
            : this(TagCodes.DefineMorphShape, len, offset)
        {

        }

        protected DefineMorphShapeTag(TagCodes code, int len, int offset)
            : base(code, len, offset)
        {

        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            CharacterId = reader.ReadUInt16();

            StartBounds = new RectangleRecord();
            StartBounds.SwfDeserialize(reader);

            EndBounds = new RectangleRecord();
            EndBounds.SwfDeserialize(reader);

            Offset = reader.ReadUInt32();

            MorphFillStyles = new MorphFillStyleArray();
            MorphFillStyles.SwfDeserialize(reader);

            MorphLineStyles = new MorphLineStyleArray(TagCode);
            MorphLineStyles.SwfDeserialize(reader);

            StartEdges = new Shape(ShapeType.Shape2);
            StartEdges.SwfDeserialize(reader);

            EndEdges = new Shape(ShapeType.Shape2);
            EndEdges.SwfDeserialize(reader);
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }
    }
}
